
<%@ page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8" %>
<%@page isELIgnored="false" %>
<html>
<head>
  <title>add Emp</title>
  <link rel="stylesheet" type="text/css"
        href="${pageContext.request.contextPath}/view/css/style.css" />
  <script type="text/javascript" src="${pageContext.request.contextPath}/view/jquery-1.8.3.js"></script>
  <script type="text/javascript">

    $(function () {

    $.ajax({
      type:"get",
      url:"${pageContext.request.contextPath}/emp/showAllDept",
      success:function (result) {
        $("#d1").empty();
      for (var i = 0;i<result.length;i++){
        $("#d1").prop("name","id");
        $("<option value='"+result[i].id+"'>"+result[i].name+"</option>").appendTo($("#d1"));


      }
      }
    })
      
      <%--$("#s1").click(function () {--%>
      <%--  var id = $("#d1 option:selected").val();--%>
      <%--  alert(id);--%>

      <%--  $.ajax({--%>
      <%--    type:"get",--%>
      <%--    url:"${pageContext.request.contextPath}/AddAction3",--%>
      <%--    data:"id="+id,--%>
      <%--    dataType:"json",--%>
      <%--    success:function (result) {--%>
      <%--     alert("111");--%>
      <%--      }--%>

      <%--  })--%>

      <%--})--%>







    })



  </script>
</head>
<body>
<div id="wrap">
  <div id="top_content">
    <div id="header">
      <div id="rightheader">
        <p>
          2009/11/20
          <br />
        </p>
      </div>
      <div id="topheader">
        <h1 id="title">
          <a href="#">Main</a>
        </h1>
      </div>
      <div id="navigation">
      </div>
    </div>
    <div id="content">
      <p id="whereami">
      </p>
      <h1>
        add Emp info:
      </h1>
      <form action="${pageContext.request.contextPath}/emp/addEmp" method="post">
        <table cellpadding="0" cellspacing="0" border="0"
               class="form_table">
          <tr>
            <td valign="middle" align="right">
              name:
            </td>
            <td valign="middle" align="left">
              <input type="text" class="inputgri" name="name" />
            </td>
          </tr>
          <tr>
            <td valign="middle" align="right">
              salary:
            </td>
            <td valign="middle" align="left">
              <input type="text" class="inputgri" name="salary" />
            </td>
          </tr>
          <tr>
            <td valign="middle" align="right">
              age:
            </td>
            <td valign="middle" align="left">
              <input type="text" class="inputgri" name="age" />
            </td>
          <tr>
            <td  align="left">
              所属部门:
              <select id="d1" >
                  <option>部门名称</option>
              </select>
            </td>
          </tr>
          </tr>
        </table>
        <p>
          <input type="submit" class="button" value="提交" id="s1"/>
        </p>
      </form>
    </div>
  </div>
  <div id="footer">
    <div id="footer_bg">
      ABC@126.com
    </div>
  </div>
</div>
</body>
</html>
